package health.lm.com.find.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ImageView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.lm.sjy.titlebar.widget.CommonTitleBar;
import com.vondear.rxtool.RxSPTool;

import butterknife.BindView;
import butterknife.ButterKnife;
import health.lm.com.component_base.base.mvp.activity.XActivity;
import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.data.AppModel;
import health.lm.com.find.R;
import health.lm.com.find.R2;
import health.lm.com.find.entity.QRCodeEntity;
import health.lm.com.find.model.ExperienceModel;
import health.lm.com.network.callback.SimpleCallBack;
import health.lm.com.router.ARouterConstant;

import static com.lm.sjy.titlebar.widget.CommonTitleBar.ACTION_LEFT_BUTTON;

/**
 * @author GQI
 * @description: 扫码进场
 * @date :2019-08-14 15:25
 */
@Route(path = ARouterConstant.QrCodeActivity)
public class QRCodeActivity extends XActivity {
    @BindView(R2.id.title_bar)
    CommonTitleBar titlebar;
    @BindView(R2.id.iv_qr_code)
    ImageView ivQrCode;
    @Autowired
    String id;

    @Override
    public int getLayoutId() {
        return R.layout.activity_qr_code;
    }

    @Override
    public Object newP() {
        return null;
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        titlebar.setListener((v, action, extra) -> finish());
        if (TextUtils.isEmpty(id)) id = RxSPTool.getString(context, AppModel.my_activity_id);
        ExperienceModel.getInstance().viewQrCode(id, new SimpleCallBack<QRCodeEntity>() {
            @Override
            public void onSuccess(QRCodeEntity pQRCodeEntity) {
                ImageLoaderHelper.getInstance().load(context,pQRCodeEntity.getImg_url(),ivQrCode);
            }
        });
    }
}
